Micron Document
๐ŸŽ–๏ธGitะฏั€ะฐ๐ŸŽ–๏ธ


Displaying Raw โ€ข View rendered โ€ข Download

docs/en/developer/transport.md fix/docs-metadata-compile-navigationevent (53a02109) Text, 3.23 KB

---
title: Transport
parent: Developer Guide
nav_order: 5
last_updated: 2026-07-07
aliases:
Tff7b72- ble
Tff7b72- serial
Tff7b72- tcp
Tc9d1d9 - radio-transport
Tc9d1d9---

Tc9d1d9# Transport

Meshtastic communicates between the app and radio hardware through multiple transport mechanisms.

Tc9d1d9## Transport Abstraction

The transport layer is abstracted through interfaces defined in Ta5d6ff`core:repository` (Ta5d6ff`RadioTransport`, Ta5d6ff`RadioTransportFactory`, Ta5d6ff`RadioInterfaceService`), with the concrete transports implemented in Ta5d6ff`core:network` (Ta5d6ff`BleRadioTransport`, TCP, mock/replay) and Ta5d6ff`core:ble`. This lets the app work identically regardless of the underlying connection type.

Ta5d6ff```
App โ† RadioController โ†’ Transport (BLE | Serial | TCP)
```

Tc9d1d9## Bluetooth Low Energy (BLE)

**Module:** Ta5d6ff`core:ble`
**Platforms:** Android, Desktop (JVM via Kable), iOS (planned)

The primary transport for mobile devices and also available on desktop:
Tff7b72- Service discovery for Meshtastic GATT services
Tff7b72- Characteristic-based read/write for protobuf packets
Tff7b72- Connection state management and automatic reconnection
Tff7b72- MTU negotiation for optimal packet sizes

Tc9d1d9### Key Classes

Tff7b72- Ta5d6ff`core/ble/` โ€” BLE scanning, connection, and GATT operations
Tff7b72- Platform-specific implementations in Ta5d6ff`androidMain` and Ta5d6ff`jvmMain` (Kable)

Tc9d1d9## USB Serial

**Module:** Ta5d6ff`core:network`
**Platforms:** Android (OTG), Desktop

Serial communication over USB:
Tff7b72- Uses Ta5d6ff`usb-serial-for-android` library on Android
Tff7b72- Direct serial port access on Desktop (JVM)
Tff7b72- Probe table for supported USB vendor/product IDs
Tff7b72- Automatic detection when USB device is connected

Tc9d1d9### Key Classes

Tff7b72- Serial prober and transport factory in Ta5d6ff`core/network`
Tff7b72- Desktop-specific serial in Ta5d6ff`desktopApp/src/main/kotlin/.../radio/`

Tc9d1d9## TCP/IP

**Module:** Ta5d6ff`core:network`
**Platforms:** Android, Desktop (iOS: code compiles, but there's no iOS app target or Ta5d6ff`RadioTransportFactory` yet โ€” see Transport Factory below)

Network-based transport for WiFi-enabled radios:
Tff7b72- TCP socket connection to radio's IP address
Tff7b72- Default port: 4403
Tff7b72- Used for development with simulated radios
Tff7b72- Available when BLE/USB is impractical

Tc9d1d9## Transport Factory

The Ta5d6ff`RadioTransportFactory` interface abstracts transport creation:

Ta5d6ff```Ta5d6ffkotlin
Tff7b72interface T56d364RadioTransportFactory Tb4b4b4{
Tff7b72val Te6edf3supportedDeviceTypesTb4b4b4: Te6edf3ListTff7b72<Te6edf3DeviceTypeTff7b72>
Tff7b72fun Td2a8ffcreateTransportTb4b4b4(Te6edf3addressTb4b4b4: Tffa657StringTb4b4b4, Te6edf3serviceTb4b4b4: Te6edf3RadioInterfaceServiceTb4b4b4)Tb4b4b4: Te6edf3RadioTransport
Tff7b72fun Td2a8ffisMockTransportTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean
Tff7b72fun Td2a8ffisAddressValidTb4b4b4(Te6edf3addressTb4b4b4: Tffa657String?Tb4b4b4)Tb4b4b4: Tffa657Boolean
Tff7b72fun Td2a8fftoInterfaceAddressTb4b4b4(Te6edf3interfaceIdTb4b4b4: Te6edf3InterfaceIdTb4b4b4, Te6edf3restTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Tffa657String
Tb4b4b4}
Ta5d6ff```

Platform-specific implementations:
Tff7b72- **Android:** Supports BLE + USB + TCP
Tff7b72- **Desktop:** Supports BLE (Kable) + USB + TCP
Tff7b72- **iOS:** Planned BLE + TCP

Tc9d1d9## Connection Lifecycle

Tff7b721. **Discovery** โ€” Scan for available radios (BLE scan / USB detect / manual TCP)
Tff7b722. **Connection** โ€” Establish link to selected radio
Tff7b723. **Handshake** โ€” Exchange node info and configuration
Tff7b724. **Active** โ€” Normal message exchange
Tff7b725. **Disconnection** โ€” Clean teardown or error recovery

Tc9d1d9## Adding a New Transport

Tff7b721. Implement Ta5d6ff`RadioTransport` interface
Tff7b722. Register in platform-specific Ta5d6ff`RadioTransportFactory`
Tff7b723. Add connection UI in Ta5d6ff`feature:connections`
Tff7b724. Update DI bindings for the platform

---

Served by rngit 1.5.0 - Generated in 0.06s